home *** CD-ROM | disk | FTP | other *** search
- <xsl:stylesheet version="1.0"
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- xmlns:msxsl="urn:schemas-microsoft-com:xslt"
- xmlns:testmap="testmap"
- exclude-result-prefixes="xsl testmap map-foldl-func"
- xmlns:map-foldl-func="map-foldl-func"
- >
- <!-- <xsl:import href="str-map.xsl"/> -->
-
- <map-foldl-func:map-foldl-func/>
-
- <testmap:testmap/>
-
- <xsl:output omit-xml-declaration="yes" indent="yes"/>
-
- <xsl:template match="/">
- <xsl:variable name="vTestMap" select="document('')/*/testmap:*[1]"/>
- <xsl:call-template name="str-map">
- <xsl:with-param name="pFun" select="$vTestMap"/>
- <xsl:with-param name="pStr" select="'0123456789'"/>
- </xsl:call-template>
- </xsl:template>
-
- <xsl:template name="double" match="*[namespace-uri() = 'testmap']">
- <xsl:param name="arg1"/>
-
- <xsl:value-of select="2 * $arg1"/>
- </xsl:template>
-
- <xsl:template name="str-map">
- <xsl:param name="pFun" select="/.."/>
- <xsl:param name="pStr" select="/.."/>
-
- <xsl:variable name="vFoldlFun" select="document('')/*/map-foldl-func:*[1]"/>
-
- <xsl:variable name="vFuncComposition">
- <xsl:copy-of select="$vFoldlFun"/>
- <xsl:copy-of select="$pFun"/>
- </xsl:variable>
-
- <xsl:variable name="vFComposition"
- select="msxsl:node-set($vFuncComposition)/*"/>
-
- <xsl:call-template name="str-foldl">
- <xsl:with-param name="pFunc" select="$vFComposition"/>
- <xsl:with-param name="pStr" select="$pStr"/>
- <xsl:with-param name="pA0" select="/.."/>
- </xsl:call-template>
- </xsl:template>
-
-
- <xsl:template name="mapL" match="*[namespace-uri() = 'map-foldl-func']">
- <xsl:param name="arg0" select="/.."/>
- <xsl:param name="arg1" select="/.."/>
- <xsl:param name="arg2" select="/.."/>
-
- <!-- $arg1 must be A0 -->
- <xsl:copy-of select="$arg1"/>
-
- <xsl:apply-templates select="$arg0[1]">
- <xsl:with-param name="arg1" select="substring($arg2,1,1)"/>
- </xsl:apply-templates>
- </xsl:template>
-
- <xsl:template name="str-foldl">
- <xsl:param name="pFunc" select="/.."/>
- <xsl:param name="pA0"/>
- <xsl:param name="pStr"/>
-
- <xsl:choose>
- <xsl:when test="not(string($pStr))">
- <xsl:copy-of select="$pA0"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:variable name="vFunResult">
- <xsl:apply-templates select="$pFunc[1]">
- <xsl:with-param name="arg0" select="$pFunc[position() > 1]"/>
- <xsl:with-param name="arg1" select="$pA0"/>
- <xsl:with-param name="arg2" select="substring($pStr,1,1)"/>
- </xsl:apply-templates>
- </xsl:variable>
-
- <xsl:call-template name="str-foldl">
- <xsl:with-param name="pFunc" select="$pFunc"/>
- <xsl:with-param name="pStr" select="substring($pStr,2)"/>
- <xsl:with-param name="pA0" select="$vFunResult"/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
-
- </xsl:template>
-
-
-
- </xsl:stylesheet>